Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to use the new flags system in script #70

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

joamaki
Copy link
Contributor

@joamaki joamaki commented Dec 13, 2024

Use the new pflag-based system for specifying flags for script commands (cilium/hive#30).

This will be a slightly breaking change, e.g. -format becomes --format etc., so will need a manual bump + potential fixes in cilium/cilium once merged.

Copy link

github-actions bot commented Dec 13, 2024

$ make test
go: downloading golang.org/x/sys v0.17.0
go: downloading golang.org/x/tools v0.17.0
go: downloading golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
go: downloading github.com/fsnotify/fsnotify v1.7.0
go: downloading github.com/sagikazarmark/slog-shim v0.1.0
go: downloading github.com/spf13/afero v1.11.0
go: downloading github.com/spf13/cast v1.6.0
go: downloading github.com/subosito/gotenv v1.6.0
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/magiconair/properties v1.8.7
go: downloading github.com/pelletier/go-toml/v2 v2.1.0
go: downloading golang.org/x/text v0.14.0
	github.com/cilium/statedb/reconciler/benchmark		coverage: 0.0% of statements
	github.com/cilium/statedb/reconciler/example		coverage: 0.0% of statements
ok  	github.com/cilium/statedb	26.366s	coverage: 82.3% of statements
ok  	github.com/cilium/statedb/index	0.004s	coverage: 28.7% of statements
ok  	github.com/cilium/statedb/internal	0.011s	coverage: 46.7% of statements
ok  	github.com/cilium/statedb/part	2.557s	coverage: 83.2% of statements
ok  	github.com/cilium/statedb/reconciler	0.195s	coverage: 88.5% of statements
-----
$ make bench
go test ./... -bench . -benchmem -test.run xxx
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb
cpu: AMD EPYC 7763 64-Core Processor                
BenchmarkDB_WriteTxn_1-4                    	  442023	      2680 ns/op	    373110 objects/sec	    2816 B/op	      32 allocs/op
BenchmarkDB_WriteTxn_10-4                   	 1000000	      1005 ns/op	    995410 objects/sec	     743 B/op	      10 allocs/op
BenchmarkDB_WriteTxn_100-4                  	 1463749	       770.9 ns/op	   1297246 objects/sec	     594 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_1000-4                 	 1491379	       804.2 ns/op	   1243524 objects/sec	     550 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_100_SecondaryIndex-4   	  495412	      2339 ns/op	    427559 objects/sec	    1504 B/op	      37 allocs/op
BenchmarkDB_Modify-4                        	    1299	    995632 ns/op	   1004389 objects/sec	  772015 B/op	    8460 allocs/op
BenchmarkDB_GetInsert-4                     	    1208	   1016096 ns/op	    984160 objects/sec	  760463 B/op	    8466 allocs/op
BenchmarkDB_RandomInsert-4                  	    2367	    505500 ns/op	   1978238 objects/sec	  402265 B/op	    7097 allocs/op
BenchmarkDB_RandomReplace-4                 	     314	   3809440 ns/op	    262506 objects/sec	 2357713 B/op	   48571 allocs/op
BenchmarkDB_SequentialInsert-4              	    1520	    811747 ns/op	   1231911 objects/sec	  551132 B/op	    7287 allocs/op
BenchmarkDB_Changes_Baseline-4              	    1254	    959438 ns/op	   1042278 objects/sec	  553143 B/op	   10252 allocs/op
BenchmarkDB_Changes-4                       	     690	   1727847 ns/op	    578755 objects/sec	  993167 B/op	   14493 allocs/op
BenchmarkDB_RandomLookup-4                  	   19510	     61156 ns/op	  16351607 objects/sec	     160 B/op	       1 allocs/op
BenchmarkDB_SequentialLookup-4              	   22004	     54447 ns/op	  18366674 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_Prefix_SecondaryIndex-4         	    7624	    146801 ns/op	   6811949 objects/sec	   93901 B/op	    1044 allocs/op
BenchmarkDB_FullIteration_All-4             	     816	   1452225 ns/op	  68859982 objects/sec	     480 B/op	      12 allocs/op
BenchmarkDB_FullIteration_Get-4             	     193	   6272735 ns/op	  15942044 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_PropagationDelay-4              	  482722	      2366 ns/op	        20.00 50th_µs	        24.00 90th_µs	        67.00 99th_µs	    1589 B/op	      24 allocs/op
PASS
ok  	github.com/cilium/statedb	26.972s
PASS
ok  	github.com/cilium/statedb/index	0.004s
PASS
ok  	github.com/cilium/statedb/internal	0.003s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/part
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_Insert_RootOnlyWatch-4    	    9216	    130838 ns/op	   7643017 objects/sec	  104163 B/op	    2041 allocs/op
Benchmark_Insert-4                  	    6176	    183380 ns/op	   5453148 objects/sec	  219062 B/op	    3064 allocs/op
Benchmark_Modify-4                  	    7828	    153080 ns/op	   6532542 objects/sec	  212628 B/op	    1205 allocs/op
Benchmark_GetInsert-4               	    6530	    181968 ns/op	   5495479 objects/sec	  212574 B/op	    1204 allocs/op
Benchmark_Replace-4                 	27011996	        44.14 ns/op	  22655170 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Replace_RootOnlyWatch-4   	27006880	        44.41 ns/op	  22517035 objects/sec	       0 B/op	       0 allocs/op
Benchmark_txn_1-4                   	 2933402	       408.1 ns/op	   2450229 objects/sec	     448 B/op	       7 allocs/op
Benchmark_txn_10-4                  	 7327784	       161.9 ns/op	   6176769 objects/sec	     154 B/op	       2 allocs/op
Benchmark_txn_100-4                 	 8162895	       147.7 ns/op	   6768990 objects/sec	     224 B/op	       2 allocs/op
Benchmark_txn_1000-4                	 7271724	       164.7 ns/op	   6071367 objects/sec	     216 B/op	       2 allocs/op
Benchmark_txn_delete_1-4            	 3175704	       374.4 ns/op	   2670787 objects/sec	     856 B/op	       6 allocs/op
Benchmark_txn_delete_10-4           	 9003210	       132.8 ns/op	   7530688 objects/sec	     132 B/op	       1 allocs/op
Benchmark_txn_delete_100-4          	11027954	       107.2 ns/op	   9324351 objects/sec	      60 B/op	       1 allocs/op
Benchmark_txn_delete_1000-4         	11873731	       100.7 ns/op	   9925895 objects/sec	      26 B/op	       1 allocs/op
Benchmark_Get-4                     	   38176	     30994 ns/op	  32264272 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Iterate-4                 	  179398	      6985 ns/op	 143164486 objects/sec	      80 B/op	       3 allocs/op
Benchmark_Hashmap_Insert-4          	   16088	     74621 ns/op	  13401041 objects/sec	   86558 B/op	      64 allocs/op
Benchmark_Hashmap_Get_Uint64-4      	  160134	      7426 ns/op	 134666395 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Hashmap_Get_Bytes-4       	  153223	      7762 ns/op	 128838827 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Uint64Map_Random-4        	    1335	    887202 ns/op	   1127139 items/sec	 2702307 B/op	    9039 allocs/op
Benchmark_Uint64Map_Sequential-4    	    1429	    839048 ns/op	   1191829 items/sec	 2492405 B/op	    9749 allocs/op
PASS
ok  	github.com/cilium/statedb/part	28.377s
PASS
ok  	github.com/cilium/statedb/reconciler	0.004s
?   	github.com/cilium/statedb/reconciler/benchmark	[no test files]
?   	github.com/cilium/statedb/reconciler/example	[no test files]
go run ./reconciler/benchmark -quiet
1000000 objects reconciled in 2.93 seconds (batch size 1000)
Throughput 341679.17 objects per second
Allocated 6011296 objects, 424764kB bytes, 533528kB bytes still in use

Use the new pflag-based system for specifying flags for
script commands.

Signed-off-by: Jussi Maki <[email protected]>
@joamaki joamaki force-pushed the pr/joamaki/pflag-fixup branch from d0cce89 to 86a2ad0 Compare December 13, 2024 12:18
@joamaki joamaki marked this pull request as ready for review December 13, 2024 12:24
@joamaki joamaki requested a review from a team as a code owner December 13, 2024 12:24
@joamaki joamaki requested review from pippolo84 and removed request for a team December 13, 2024 12:24
Copy link
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@joamaki joamaki merged commit cc7f961 into main Dec 16, 2024
1 check passed
@joamaki joamaki deleted the pr/joamaki/pflag-fixup branch December 16, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants